<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <!--          <a-col :span="24">-->
          <!--            <j-multi-select-tag-->
          <!--              v-model="model.jingId"-->
          <!--              dictCode="ytsj_jdjcxx,jing_id,jing_id"-->
          <!--              placeholder="请选则邻井井号"-->
          <!--              @change="chang"-->
          <!--            >-->

          <!--            </j-multi-select-tag>-->
          <!--            <span>已选择的井号为：{{model.jingId}}</span>-->
          <!--            &lt;!&ndash;            <jdjcxx></jdjcxx>&ndash;&gt;-->
          <!--          </a-col>-->
          <a-col :span="24">



           <YtsjPyszzbList></YtsjPyszzbList>
           <YtsjPysbList></YtsjPysbList>


          </a-col>
          <a-col :span="20" style="text-align: center">
            <a-form-item :wrapperCol="{span: 19, offset: 5}">
              <a-button  @click="prevStep">上一步</a-button>
              <a-button style="margin-left: 8px" type="primary" @click="nextStep" v-show="true">下一步</a-button>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

    import { httpAction, getAction } from '@/api/manage'
    import { validateDuplicateValue } from '@/utils/util'
    import YtsjPyszzbList from "../YtsjPyszzbList";
    import YtsjPysbList from "../YtsjPysbList";


    export default {
        name: 'YtsjJdjcxxForm',
        components: {

            YtsjPyszzbList,
            YtsjPysbList
        },
        props: {


            chuanguo:{},
            //表单禁用
            disabled: {
                type: Boolean,
                default: false,
                required: false
            },
            chuancan: { type: Function },

        },
        data () {
            return {
                //用于传递选择的井id
                haha1:{},
                chuanguolaidezhi:{},

                counts:{

                },
                model:{
                },
                labelCol: {
                    xs: { span: 24 },
                    sm: { span: 5 },
                },
                wrapperCol: {
                    xs: { span: 24 },
                    sm: { span: 16 },
                },
                confirmLoading: false,
                validatorRules: {
                    jingId: [
                        { required: true, message: '请输入井id号!'},
                    ],
                },
                url: {
                    add: "/jdjcxx/ytsjJdjcxx/add",
                    edit: "/jdjcxx/ytsjJdjcxx/edit",
                    queryById: "/jdjcxx/ytsjJdjcxx/queryById"
                },
                isadd:false,
                isxianshi:{

                },
            }
        },
        computed: {
            formDisabled(){
                return this.disabled
            },
        },

        created () {
            //备份model原始值
            this.modelDefault = JSON.parse(JSON.stringify(this.model));
        },
        methods: {
            //用于传递选择的井id
            haha(record){
                this.haha1 = record;
                console.log(record+"这是传过来的选择的井·。。。。id")
            },

            //传递选择的jingId


            //传递id值
            // chang(){
            //
            //     // this.counts = this.model.jingId;
            //     // console.log(this.counts+"传递的id")
            //     // globalBus.$emit('countNumber', this.counts);
            //     // console.log(globalBus)
            //     this.chuancan(this.model.jingId);
            //     this.isxianshi = this.model.jingId
            // },
            prevStep () {
                this.$emit('prevStep')
            },
            nextStep () {
                this.$emit('nextStep')
            },
            add () {
                this.edit(this.modelDefault);
                this.isadd =true;
            },
            edit (record) {
                this.model = Object.assign({}, record);
                this.visible = true;
            },
            submitForm () {
                const that = this;
                // 触发表单验证
                this.$refs.form.validate(valid => {
                    if (valid) {
                        that.confirmLoading = true;
                        let httpurl = '';
                        let method = '';
                        // if(!this.model.id){
                        //   httpurl+=this.url.add;
                        //   method = 'post';
                        // }else{
                        //   httpurl+=this.url.edit;
                        //    method = 'put';
                        // }
                        if (this.isadd){
                            httpurl+=this.url.add;
                            method = 'post';
                            // this.isxianshi = false;
                        }else {
                            httpurl+=this.url.edit;
                            method = 'put';
                        }
                        httpAction(httpurl,this.model,method).then((res)=>{
                            if(res.success){
                                that.$message.success(res.message);
                                that.$emit('ok');
                            }else{
                                that.$message.warning(res.message);
                            }
                        }).finally(() => {
                            that.confirmLoading = false;
                            this.isadd = false
                        })
                    }

                })
            },
        }
    }
</script>